package com.qqtech.qquan.draw.dao;

import java.util.List;

import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.data.domain.Page;
import org.springframework.data.domain.PageImpl;
import org.springframework.data.domain.Pageable;
import org.springframework.stereotype.Repository;

import com.qqtech.core.common.util.BeanUtil;
import com.qqtech.core.frame.dao.BaseDaoImpl;
import com.qqtech.qquan.draw.model.DrawItem;
import com.qqtech.qquan.draw.model.DrawItemQuery;
import com.qqtech.qquan.draw.model.DrawItemVo;

@Repository
public class DrawItemDaoImpl extends BaseDaoImpl<DrawItem> implements DrawItemDao {
	public static final Logger log = LoggerFactory.getLogger(DrawItemDaoImpl.class);

	@Override
	public Page<DrawItemVo> queryPageListAdmin(DrawItemQuery query, Pageable pageable) {
		List<DrawItemVo> contentList = sqlSessionTemplate.selectList(getSqlName("selectAdmin"),
				getParams(query, pageable));
		return new PageImpl<DrawItemVo>(contentList, pageable, this.queryCountAdmin(query));
	}
	
	@Override
	public int queryCountAdmin(DrawItemQuery query) {
		return sqlSessionTemplate.selectOne(getSqlName("selectCountAdmin"), BeanUtil.toMap(query));
	}
}
